var _UrlPrefix = "http://www.fuzhuangchangongxiao.cn/";

(function ($) {
    var index = {
        init: function () {
            vm = new Vue({
                el: "#Index",
                // 数据
                data: {
                    currBtn: 1,
                    phone: '',
                    isCheck: true
                },

                // 周期
                mounted: function () {},

                // 侦听器
                watch: {},

                // 计算属性
                computed: {

                },

                // 方法
                methods: {
                    onSelectType (_value) {
                        // 选择注册类型
                        this.currBtn = _value
                    },
                    onNextStep () {
                        // 提交信息
                        var self = this
                        if(self.phone.length > 0) {
                            if(self.phone.length != 11) {
                                self.onErr()
                                return
                            }
                            for(var i = 0;i < self.phone.length;i++) {
                                if(self.phone[i] < '0' || self.phone[i] > '9') {
                                    self.onErr()
                                    return
                                }
                            } 
                        }
                        $.ajax({
                            type:"POST",
                            url: _UrlPrefix + "api/web/user/set-type",
                            data: {
                                type: self.currBtn,
                                introducer: self.phone,
                                token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJtYy5jb20iLCJhdWQiOiJtYy5jb20iLCJqdGkiOiJsXzVkODg0NDJkODFiNTY2LjExMjU0MjUxIiwiaWF0IjoxNTY5MjExNDM3LCJuYmYiOjE1NjkyMTg2MzcsImV4cCI6MTU2OTIyMjIzNywidWlkIjo3MCwidHlwZSI6MH0.FGpNCFQkT6GULDoCzjkGpzcmcROYMS_kUBD2OKNHaSSMBn5Fh1-1m9w11jAwxNWtkWj9r3G6aZGoxI-AhWojbw-8-AYO6ZjMlnSBygmT5gGFt1hA1E8Lc6Rd0d7m-FgszTrpCd9aMXr3meQwqOE48sKlkeCKV01DLC2Xuf22xnxWa3zTiPgNnChaXM-0MnA3FvAxq2YdIsVC5v5_1SW7NOnQHqN-yqI_5ytWRNjslG9_-XfksiyiYteZpPJHpFU7DHEn_2oaFfE3sUO6nHUt-6a7-BXc0I7AN9BW7Afra9k5BATbewZ-j2ydKFzFPAyoU8jKNfbSIpa7JRhOrJJW2g'
                            },
                            success:function(res){
                                if(res.code == 200) {
                                    alert("选择成功")
                                }else if(res.code == 30002) {
                                    console.log(res.data)
                                }
                            },
                            error: function(xhr,status,error) {
                                // console.log("xhr:", xhr)
                                // console.log("status:", status)
                                // console.log("error:", error)
                            },
                            complete: function () {

                            }
                        })
                    },
                    onErr () {
                        var self = this
                        self.isCheck = false
                        setTimeout(function () {
                            self.isCheck = true
                        }, 1000)
                    }
                },

                // 周期
                created: function () {},
            })
        }
    }
    index.init()
})(jQuery)